package com.sc.nft.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dao.CopyrightAuctionRecordDao;
import com.sc.nft.entity.CopyrightAuctionRecord;
import com.sc.nft.entity.dto.CopyrightAuctionRecordAdminListDTO;
import com.sc.nft.entity.vo.CopyrightAuctionRecordAdminListVO;
import com.sc.nft.entity.vo.CopyrightAuctionRecordUserListVO;
import com.sc.nft.service.CopyrightAuctionRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 版权拍卖记录 服务实现类
 * </p>
 *
 * @author liGen
 * @since 2024-09-12
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class CopyrightAuctionRecordServiceImpl implements CopyrightAuctionRecordService {

    private final CopyrightAuctionRecordDao copyrightAuctionRecordDao;


    /**
     * 当前用户拍卖记录
     * @param userId
     * @param mp
     * @return
     */
    @Override
    public IPage<CopyrightAuctionRecordUserListVO> copyrightAuctionRecordUserList(Long userId, Page mp) {
        return copyrightAuctionRecordDao.copyrightAuctionRecordUserList(userId, mp);
    }

    /**
     * 后台拍卖记录
     * @param copyrightAuctionRecordAdminListDTO
     * @return
     */
    @Override
    public IPage<CopyrightAuctionRecordAdminListVO> copyrightAuctionRecordAdminUserList(CopyrightAuctionRecordAdminListDTO copyrightAuctionRecordAdminListDTO){
        return copyrightAuctionRecordDao.copyrightAuctionRecordAdminUserList(copyrightAuctionRecordAdminListDTO.toMp(), copyrightAuctionRecordAdminListDTO.getFirstTitle());
    }

    /**
     * 获取已经开始并且未生成拍卖结果的记录
     *
     * @param now
     * @return
     */
    @Override
    public List<CopyrightAuctionRecord> getNotHaveResultList(Date now) {
        return copyrightAuctionRecordDao.getNotHaveResultList(now);
    }

    /**
     * 修改是否生成拍卖结果
     *
     * @param id
     * @param haveResult
     * @return
     */
    @Override
    public Boolean updateHaveResult(Long id, Boolean haveResult) {
        return copyrightAuctionRecordDao.updateHaveResult(id, haveResult);
    }

}
